﻿using ComClassLibrary;
using KeyboardArg;
using System;
using System.Windows;

namespace SelectKeyBoard
{
    /// <summary>
    /// App.xaml 的交互逻辑
    /// </summary>
    public partial class App : Application
    {  
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            string jsonString = "";
            if (e.Args.Length <= 0)
            {
                jsonString = "{\"Content\":\"中国\",\"DictionaryFileName\":\"VehicleType\",\"Key\":\"GJ\",\"Lang\":\"cn\",\"MaxLength\":5,\"Title\":\"\",\"Value\":null,\"VoiceFileName\":null,\"Wnd\":{\"value\":5835392}}";               
            }
            else
            {
                jsonString = e.Args[0].Replace('@', '"'); ;
            }
            KeyBoardArgs keyboardArg = null;
            try
            {
                keyboardArg = JsonHandler.ConvertToJsonObject<KeyBoardArgs>(jsonString);
            }
            catch (Exception ex)
            {
                Console.WriteLine(e);
                MessageBox.Show(e.ToString(), "参数错误");
                //throw;
            }
            //keyboardArg = JsonHandler.ConvertToJsonObject<InputToolArg>(strCmdLine);
            if (null == keyboardArg)
            {
                MessageBox.Show(jsonString, "参数错误"); //20170412 取消提示
                return;
            }
            else
            {
                MainWindow mainWindow = new MainWindow(keyboardArg);
                mainWindow.Show();
            }

            //StartupUri="MainWindow.xaml" 
            
        }   
    }

    
}
